class PollController < ApplicationController

  def index
    user = User.find(session[:user_id])
    grid_id = params[:grid_id]
    events = GridEvent.find_waiting_events(session[:user_id], grid_id)
    if (events.empty?)
      head 204
    else
      events.each do |event|
        event.users.delete(user)
      end
      data = '{"data": ' + GridEvent.to_json(events) + '}'
      render :text => data
    end
  end

end
